package com.example.verifysdk.compare;

import android.content.Context;

import com.example.verifysdk.LogUtil;
import com.example.verifysdk.UploadHelper;

import java.util.concurrent.TimeUnit;

import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

/**
 *
 * @author LiuV
 * @date 2017/4/26
 */

public class CompareModel {

    private static final String TAG = "CompareModel";

    public void submitInfoModel(
            String partner,
            String partnerRemark,
            String id,
            String name,
            String phone,
            String totp,
            Callback callback) {
        LogUtil.i(TAG, "---submitInfoModel===api/reg/addPartnerUser");

        RequestBody requestBody = new FormBody.Builder()
                .add("partner", partner)
                .add("partnerRemark", partnerRemark)
                .add("id", id)
                .add("name", name)
                .add("phone", phone)
                .build();

        LogUtil.i(TAG, "---submitInfoModel===");
        Request request = new Request
                .Builder()
                .url(UploadHelper.getUrl(null) + "api/reg/addPartnerUser/" + totp)
                .post(requestBody)
                .build();
        OkHttpClient client = new OkHttpClient
                .Builder()
                .connectTimeout(10, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .build();
        client.newCall(request).enqueue(callback);
    }

    public void infoIsOk(Context context, String token, Callback callback){
        LogUtil.i(TAG, "---infoIsOk===api/updateIsAppVerify");

        Request request = new Request
                .Builder()
                .addHeader("APP_TOKEN", token)
                .url(UploadHelper.getUrl(context) + "api/updateIsAppVerify")
                .get()
                .build();
        OkHttpClient client = new OkHttpClient
                .Builder()
                .connectTimeout(10, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .build();
        client.newCall(request).enqueue(callback);
    }
}
